{# SPDX-FileCopyrightText: © 2014-2015 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
{% extends "include/base.html.twig" %}


{% block content %}

<table class="semibordered" id="licenseCandidateTbl" width="100%" cellpadding="0">
  <thead>
    <tr> {% if canEdit %}<th width="5%"></th>{% endif %}
      <th width="10%"></th>
      <th width="10%"></th>
      <th width="10%"></th>
      <th width="{% if canEdit %}45{% else %}40{% endif %}%"></th>
      <th width="10%"></th>
      <th width="10%"></th>
      <th width="5%"></th></tr>
  </thead>
</table>
{% if canEdit %} 
  <br/><br/>
  <div style="text-align:center;">
    <a href="?mod=advice_license&amp;rf=-1" class="buttonLink">{{ 'New License'|trans }}</a>
  </div>
{% endif %}  
{% endblock %}

{% block foot %}
  {{ parent() }}
  <script src="scripts/jquery.dataTables.min.js" type="text/javascript"></script>
  <script src="scripts/jquery.dataTables.select.js" type="text/javascript"></script>
  <script type="text/javascript">
    function createBrowseTable() {

    tableColumns = [
      {% if canEdit %}
        {"sTitle": "{{ "Edit"|trans }}", "sClass": "center", "bSearchable": false},
      {% endif %}
      {"sTitle": "{{ "SPDX ID"|trans }}", "sClass": "center", "bSearchable": true},
      {"sTitle": "{{ "Shortname"|trans }}", "sClass": "center", "bSearchable": true},
      {"sTitle": "{{ "Fullname"|trans }}", "sClass": "center", "bSearchable": true},
      {"sTitle": "{{ "Text"|trans }}", "sClass": "left", "bSearchable": true},
      {"sTitle": "{{ "URL"|trans }}", "sClass": "center", "bSearchable": false},
      {"sTitle": "{{ "Created By"|trans }}", "sClass": "center", "bSearchable": true},
      {"sTitle": "{{ "Merge Request"|trans }}", "sClass": "center", "bSearchable": false}
    ];

    tableSorting = [ [2, "asc"] ];

    dataTableConfig =
        {
          "aoColumns": tableColumns,
          "aaSorting": tableSorting,
          "iDisplayLength": 20,
          "aaData": {{ aaData }},
          "sPaginationType": "listbox",
          "bStateSave": true
        };

      var otable = $('#licenseCandidateTbl').dataTable(dataTableConfig);
      return otable;
    }
    
    $(document).ready(function () {
      createBrowseTable();
    });
    
  </script>
{% endblock %}
